package day13;

import java.io.*;
import java.util.Scanner;

public class TestCopyFile {
    public static void main(String[] args) {
        System.out.println("请输入复制目标文件目录");
        String f=new Scanner(System.in).nextLine();
        System.out.println("请输入复制结果文件目录");
        String t=new Scanner(System.in).nextLine();
        ZJCopy(f,t);
    }

    private static void ZJCopy(String f, String t) {
        InputStream in=null;
        OutputStream out=null;
        try {
            in=new FileInputStream(f);
            out=new FileOutputStream(t);
            int b;
            while ((b=in.read())!=-1){
                out.write(b);
            }
            System.out.println("恭喜您，复制成功！");
        } catch (Exception e) {
            System.out.println("很抱歉，复制失败！");
            e.printStackTrace();
        }finally{
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
